/* serie402.js */
var facebookLikeBaseId = "fbTD_";
var twitterTweetBaseId = "twitterTD_";
var contextRoot = "/web";
var newsLink = contextRoot +"/_pages/public/news.jsf";
var newsArticleLink = contextRoot +"/_pages/public/article.jsf";
var multimediaLink = contextRoot +"/_pages/public/multimedia/";
var eventsLink = contextRoot +"/_pages/public/events.jsf";
var shoppingLink = contextRoot +"/_pages/public/shop/";
var classifiedsLink = contextRoot +"/_pages/public/classifieds.jsf";
var archiveLink = contextRoot +"/_pages/public/archive.jsf";
var errorLink = contextRoot +"/error.jsf";


/* global functions */
function executeAjax(_url, _method, _field, _setLocation) {
	var httpRequest = null;
	
	if(window.XMLHttpRequest) {
		// code for IE7+, Firefox, Chrome, Opera, Safari
		httpRequest = new XMLHttpRequest();
	}
	else {
		try {
			httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e) {
			try {
				httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch(e){}
		}
	}
    
	// if the httpRequest object could not be initialized
	if(!httpRequest) {
		return false;
	}
    
	// else, load the confirmation page
	else {
		httpRequest.onreadystatechange = function() {
			if(httpRequest.readyState == 4 && httpRequest.status == 200) {
				if(_setLocation == "innerHTML") {
					_field.innerHTML = httpRequest.responseText;
				}
				else if(_setLocation == "innerText") {
					_field.innerText = httpRequest.responseText;
				}
				else if(_setLocation == "outerHTML") {
					_field.outerHTML = httpRequest.responseText;
				}
				else if(_setLocation == "outerText") {
					_field.outerText = httpRequest.responseText;
				}
				else {
					document.getElementById("ajaxContainerDIV").innerText = httpRequest.responseText;
				}
			}
		};
		
		httpRequest.open(_method, _url, true);
		httpRequest.send(null);
	}
}

/* navigation */
function goToPage(_page) {
	window.location.assign(_page);
}

function goToErrorPage(_errorCode) {
	goToPage(errorLink +"?code=" +_errorCode);
}

function goToNews(_newsId) {
	if(_newsId == null) {
		goToPage(newsLink);
	}
	else {
		goToPage(newsArticleLink +"?newsId=" +_newsId);
	}
}

function goToNewsCategory(_category) {
	goToPage(newsLink +"?category=" +_category);
}

function goToNewsSubCategory(_category, _subCategory) {
	goToPage(newsLink +"?category=" +_category +"&subCategory=" +_subCategory);
}

function goToMultimedia(_page) {
	goToPage(multimediaLink +_page +".jsf");
}

function goToEvent(_eventId) {
	goToPage(eventsLink +"?action=viewEvent&eventId=" +_eventId);
}

function goToPhotoAlbum(_photoAlbum) {
	goToPage(multimediaLink +"photoAlbum.jsf?albumId=" +_photoAlbum);
}

function goShopping(_page) {
	goToPage(shoppingLink +_page +".jsf");
}

function goToClassifieds(_category) {
	goToPage(classifiedsLink +"?category=" +_category);
}

function goToArchives(_archive) {
	goToPage(archiveLink +"?target=" +_archive);
}

/* news.js */
function updateTopNewsMainPhoto(_photoUrl) {
	document.getElementById("TopNewsMainImage").src = _photoUrl;
}

/* gallery.js */
function updateMainPhoto(_image) {
	alert(document.getElementById("galleryMainPhoto").style.backgroundImage);
}